* ==============================================================================================
*            REPLICATION CODE FOR              
*           TERTYTCHNAYA, KATERINA. 2023.      
* "PREVENTIVE REPRESSION & PUBLIC OPINION"      
* WORLD POLITICS, FORTHCOMING.  ##
*
*This do file contains the code for recoding the data and replicating the analysis in Stata
* ==============================================================================================


clear
cd "~/WP_Replication" /*Set your own*/

*The following packages are needed*/
ssc install estout, replace
ssc install coefplot, replace
ssc install blindschemes  
set scheme plotplain

* ==============================================================================================
* 2020 SEPTEMBER SURVEY EXPERIMENT 
* ==============================================================================================

* SET-UP THE DATA 
run Code/setup_experiment.do 

* ==============================================================================================
* Table 2 & Figure 2 in the Manuscript, see also: "Code/replicate_fig_2.R" for plots in R
* ==============================================================================================
reg supp_dem2 unauthorised##c.legal_concerns age gender education 
margins, dydx(unauthorised) at (legal_concerns=(1(1)5)) atmeans
*run marginsplot to produce the top plot of F2 (square) in Stata
*CME of unauthorized saved in Book5 for the figure in R

reg supp_dem2 violent##c.legal_concerns age gender education 
margins, dydx(violent) at (legal_concerns=(1(1)5)) atmeans
*run marginsplot to produce the middle plot of F2 (square) in Stata
* CME of violence saved in Book6 for the figure in R

reg supp_dem2 arrest##c.legal_concerns age gender education 
margins, dydx(arrest) at (legal_concerns=(1(1)5)) atmeans
*run marginsplot to produce the bottom plot of F2 (square) in Stata
* CME of arrests saved in Book7 for the figure in R

reg part_dummy2 unauthorised##c.legal_concerns age gender education 
margins, dydx(unauthorised) at (legal_concerns=(1(1)5)) atmeans
*run marginsplot to produce the top plot of F2 (diamond) in Stata
* CME of unauthorized saved in Book5 for the figure in R

reg part_dummy2 violent##c.legal_concerns age gender education 
margins, dydx(violent) at (legal_concerns=(1(1)5)) atmeans
*run marginsplot to produce the middle plot of F2 (diamond) in Stata
*CME of violence saved in Book6 for the figure in R

reg part_dummy2 arrest##c.legal_concerns age gender education 
margins, dydx(arrest) at (legal_concerns=(1(1)5)) atmeans
*run marginsplot to produce the bottom plot of F2 (diamond) in Stata
* CME of arrests saved in Book7 for the figure in R


* ==============================================================================================
* Table 3 & Figure 3 in the Manuscript, see also: "Code/replicate_fig_3.R" for plots in R=======
* Table C.5 in the Appendix ====================================================================
* ==============================================================================================
reg supp_dem2 unauthorised##violent age gender education 
margins unauthorised##violent, atmeans
margins, dydx(unauthorised) at (violent=(0(1)1)) atmeans
*run marginsplot to plot the conditional marginal effect of unauth protest in Stata 
*output saved in Book1
margins, dydx(violent) at (unauthorised=(0(1)1)) atmeans
*run marginsplot to plot the conditional marginal effect of violent tactics in Stata
*output saved in Book2 for the figure in R

reg supp_dem2 unauthorised##arrest age gender education 
margins unauthorised##arrest, atmeans
margins, dydx(unauthorised) at (arrest=(0(1)1)) atmeans
*run marginsplot to plot the conditional marginal effect of unauth protest in Stata 
*output saved in Book3
margins, dydx(arrest) at (unauthorised=(0(1)1)) atmeans
*run marginsplot to plot the conditional marginal effect of arrests in Stata 
*output saved in Book4

reg part_dummy2 unauthorised##violent age gender education 
margins unauthorised##violent, atmeans
margins, dydx(unauthorised) at (violent=(0(1)1)) atmeans
*run marginsplot to plot the conditional marginal effect of unauth protest in Stata 
*output saved in Book1
margins, dydx(violent) at (unauthorised=(0(1)1)) atmeans
*run marginsplot to plot the conditional marginal effect of violent tactics in Stata
*output saved in Book2

reg part_dummy2 unauthorised##arrest age gender education 
margins unauthorised##arrest, atmeans
margins, dydx(unauthorised) at (arrest=(0(1)1)) atmeans
*run marginsplot to plot the conditional marginal effect of unauth protest in Stata
*output saved in Book3
margins, dydx(arrest) at (unauthorised=(0(1)1)) atmeans
*run marginsplot to plot the conditional marginal effect of arrests in Stata
*output saved in Book4

* ==============================================================================================
* Appendix Figure C.2
* ==============================================================================================

*Left-hand panel
mprobit part_dummy3 unauthorised age gender education 
margins, dydx(unauthorised) atmeans
marginsplot
* Middle panel
mprobit part_dummy3 violent age gender education 
margins, dydx(violent) atmeans
marginsplot
* Right-hand panel
mprobit part_dummy3 arrest age gender education 
margins, dydx(arrest) atmeans
marginsplot


* ==============================================================================================
* Appendix Table C.3
* ==============================================================================================

reg supp_dem2 unauthorised##putin_voter age gender education 
margins unauthorised##putin_voter, atmeans
margins, dydx(unauthorised) at (putin_voter==(0(1)1)) atmeans

reg supp_dem2 unauthorised##vote_cast age gender education 
margins unauthorised##vote_cast, atmeans
margins, dydx(unauthorised) at (vote_cast==(0(1)2)) atmeans

reg part_dummy2 unauthorised##app_opp age gender education 
margins unauthorised##app_opp, atmeans
margins, dydx(unauthorised) at (app_opp==(0(1)1)) atmeans


* ==============================================================================================
* Appendix Table C.4
* ==============================================================================================
 
reg supp_dem2 violent##putin_voter age gender education if unauthorised==1
margins violent##putin_voter, atmeans
margins, dydx(violent) at (putin_voter==(0(1)1)) atmeans

reg supp_dem2 violent##putin_voter age gender education if unauthorised==0
margins violent##putin_voter, atmeans
margins, dydx(violent) at (putin_voter==(0(1)1)) atmeans

* ==============================================================================================
* Appendix Figure C.3
* ==============================================================================================
reg supp_dem2 ib2.added_tactics age gender education
margins, at (added_tactics=(1(1)4)) atmeans
marginsplot

clear

